package com.ymatou.query.trading.api.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.Logger;
import com.ymttest.utils.EnvSetup;

/**
 * 获取买家补款信息Call FreeMaker Template自动生成代码
 */
public class GetOrderPostPayInfoCall extends YmatouBaseCall {
	private static String opurl = "api/App/GetOrderPostPayInfo";

	public GetOrderPostPayInfoCall() {
		super(EnvSetup.getSystemUrl("api_order_query"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("Code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("Msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public JSONObject getData() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("Data");
		} catch (JSONException e) {
			//e.printStackTrace();
			Logger.debug("返回json data 为null");
		}
		return Data;
	}

	/**
	 * 获取账户余额
	 * 
	 * @return
	 */
	public Long getAvailAmount() {
		Long AvailAmount = null;
		try {
			AvailAmount = getData().getLong("AvailAmount");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return AvailAmount;
	}

	/**
	 * 获取补款余额
	 * 
	 * @return
	 */
	public Long getPostPayAmount() {
		Long PostPayAmount = null;
		try {
			PostPayAmount = getData().getLong("PostPayAmount");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return PostPayAmount;
	}

	/**
	 * 获取账户余额
	 * 
	 * @return
	 */
	public Long getUseGiftAmount() {
		Long UseGiftAmount = null;
		try {
			UseGiftAmount = getData().getLong("UseGiftAmount");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return UseGiftAmount;
	}

	/**
	 * 获取红包最大使用数量
	 * 
	 * @return
	 */
	public Long getGiftAvailAmount() {
		Long GiftAvailAmount = null;
		try {
			GiftAvailAmount = getData().getLong("GiftAvailAmount");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return GiftAvailAmount;
	}

	/**
	 * 获取是否设置交易密码
	 * 
	 * @return
	 */
	public boolean getExistsTradingPassword() {
		boolean type = false;
		try {
			type = getData().getBoolean("ExistsTradingPassword");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return type;
	}
}
